package main

import (
	"fmt"

	"github.com/spf13/viper"
)

type config struct {
	Post    int    `mapstructure:"post"`
	Name    string `mapstructure:"name"`
	PathMap string `mapstructure:"path_map"`
	Host    `mapstructure:"host"`
}

type Host struct {
	API  string `mapstructure:"api"`
	Time int    `mapstructure:"time"`
}

var Config = new(config)

func main() {
	viper.SetConfigFile("./manifest/config.json")

	err := viper.ReadInConfig() // 查找并读取配置文件
	if err != nil {
		panic(fmt.Errorf("Fatal error config file: %s \n", err))
	}
	err = viper.Unmarshal(&Config)
	if err != nil {
		fmt.Printf("unable to decode into struct, %v", err)
	}

	fmt.Println(Config)

}
